<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>部门规划</title>
<script type="text/javascript" src="static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="static/easyui/themes/icon.css">
</head>
<body>

<script type="text/javascript">
	/* 编辑窗口 */
	function deleteDepart(depart_id){
			alert(depart_id);
		 $("#formbj").form('load','bj-form?depart_id='+depart_id);
		 $("#bianji-department").window("open");
			$("#department-bjgb").linkbutton({onClick : function(){
				$("#bianji-department").window("close");
			}});
	}	
	/*删除*/
	function scDepart(departid){
		alert("删除成功");
		var id=departid;
		$("#tableform").form('load','delete-department?departid='+id);
	}
	/* 新增窗口 */
	function addDepart(i){
		$("#add-department").window("open");
		$("#department-gb").linkbutton({onClick : function(){
			$("#add-department").window("close");
		}});
	}
	$(function(){
		$('#table-department').datagrid({
		    url:'Department_list',
		    columns:[[
				{field:'depart_id',title:'部门编号',width:200,align:'center'},
				{field:'departName',title:'部门名称',width:200,align:'center'},
				{field:'departAddress',title:'部门地址',width:350,align:'center'},
				{field:'caozuo',title:'操作',width:350,align:'center',
					formatter: function(value,row,index){
						return "<input type='button' onclick='deleteDepart("+row['depart_id']+")' style='width: 45px;height: 20px;font-size:12px;border-radius:4px;margin-right:5px;color:#fff;background-color:#18A689;border:1px solid #18A689;' value='编辑'/>"+"<input type='button' onClick='scDepart("+row['depart_id']+")' style='width: 45px;height: 20px;font-size:12px;border-radius:4px;color:#fff;background-color:#18A689;border:1px solid #18A689;' value='删除'/>";
					},
				}
		    ]],
		    pagination:true,
		    pageNumber:1,
		    pageSize:5,
		    pageList:[5,10,15]
		});
		$("#table-department").datagrid({
			//rowData是当前选中行的数据，是json字符串格式
			onDblClickRow:function(rowIndex,rowData){
				var rows=$("#table-department").datagrid("getRows");
				$("#depart_id").textbox("setValue",rows[rowIndex].depart_id);
				$("#departName").textbox("setValue",rows[rowIndex].depart_name);
				$("#departAddress").textbox("setValue",rows[rowIndex].depart_address);
				$("#bianji-department").window("open"); 
			}
		});

		/* 新增部门 */
		$("#add-dept").click(function(){
			$("#form").submit();
			$("#form").form("clear")
			$("#add-department").window("close");
			$("#table-department").datagrid("reload");
			
		});
		/* 编辑确定 */
		$("#bjadd-dept").click(function(){
			$("#formbj").submit();
			$("#formbj").form("clear");
			$("#bianji-department").window("close");
		});
	});
</script>
	<a class="easyui-linkbutton" onClick="addDepart(this)" data-options="iconCls:'icon-add',width:200">新增</a>
	<Form action="" id="tableform" method="get">
	<table id="table-department" class="easyui-datagrid" style="height: 560px;" >
	</table> 
	</Form>
	<!-- 新增部门 -->
	<div id="add-department" class="easyui-window" title="新增部门" style="width:800px;height:300px;" 
		data-options="modal:true,collapsible:false,minimizable:false,maximizable:false,closed:true,draggable:false">  
			<Form action="add-dept" id="form" method="post">
						<div style="text-align: center;margin: 0 auto;">
				    		部门编号:<input class="easyui-textbox" name="depart_id" type="text"/><br/><br/>
							部门名称:<input name="departName" type="text"/><br/><br/>
							部门地址:<input name="departAddress" type="text"/>
							<input type="hidden"  name="depart_id"/>
							<div style="text-align: center">
								  <input id="department-gb" type="button" value="关闭" width="100px"/>
								  <input id="add-dept" type="button" value="确定" width="100px"/>
							</div>
						</div>
		 	</Form>
</div>  
	
	<!-- 部门编辑 -->
	<div id="bianji-department" class="easyui-window" title="部门编辑" style="width:800px;height:300px;" 
		data-options="modal:true,collapsible:false,minimizable:false,maximizable:false,closed:true,draggable:false">  
			<Form action="xiugai" id="formbj" method="post">
			    	${dement }
			    		部门编号:<input name="depart_id" type="text" value="${dement.depart_id }"/><br/><br/>
			    		部门名称:<input name="departName" type="text" value="${dement.departName }"/><br/><br/>
						部门地址:<input name="departAddress" type="text" value="${dement.departAddress }"/>
						<div style="text-align: center">
							  <input id="department-bjgb" type="button" value="关闭" width="100px"/>
							<input type="button" id="bjadd-dept" value="确定" width="100px"/>
						</div>
					</Form>
</div>  
	<%-- <div id="bianji-department" style="width:1366px;height:736px;position:fixed; top:0px;
	background: rgba(0, 0, 0, 0.5);text-align:center;left:0;z-index:10;display:none;" >
		<div style="width:1366px;height:736px;position:fixed; top:0px;z-index:10;">
			<div style="margin:20px auto;width:500px;height:180px;background:white;border-radius:3px;">
				<div style="width:100%;height:30px;">
					<span style="width:50px;height:30px;line-height:30px;display:inline-block;float:left;margin-left:20px;">编辑</span>
				</div>
				<div style="width:100%;height:115px;border-top:solid 1px #E5E5E5;border-bottom:solid 1px #E5E5E5;">
					<Form action="xiugai" id="formbj" method="post">
			    	${dement }
			    		部门编号:<input name="depart_id" type="text" value="${dement.depart_id }"/><br/><br/>
			    		部门名称:<input name="departName" type="text" value="${dement.departName }"/><br/><br/>
						部门地址:<input name="departAddress" type="text" value="${dement.departAddress }"/>
						<div style="text-align: center">
							  <input id="department-bjgb" type="button" value="关闭" width="100px"/>
							<input type="button" id="bjadd-dept" value="确定" width="100px"/>
						</div>
					</Form>
				</div>
			</div>
		</div>
	</div> --%>
	<%-- <div id="bianji-department" class="easyui-window" title="修改组织架构" style="width:300px;height:200px;text-align: center;display:none;"
	    data-options="iconCls:'icon-add',modal:true,collapsible:false">
	    	<Form action="add-dept" id="formbj" method="post">
	    	${dement }
	    		部门编号:<input name="depart_id" type="text" value="${dement.depart_id }"/><br/><br/>
	    		部门名称:<input name="depart_name" type="text" value="${dement.depart_name }"/><br/><br/>
				部门地址:<input name="depart_address" type="text" value="${dement.depart_address }"/>
				<div style="text-align: center">
					  <input id="department-bjgb" type="button" value="关闭" width="100px"/>
					<input type="button" id="add-dept" value="确定" width="100px"/>
				</div>
			</Form>
    </div> --%>
</body>
</html>